package com.example.lottery_system.dao.mapper;

import com.example.lottery_system.dao.dataobject.Encrypt;
import com.example.lottery_system.dao.dataobject.UserDO;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserMapper {
    @Insert("insert into user (user_name, email, phone_number, password, identity)" +
            " values (#{userName}, #{email}, #{phoneNumber}, #{password}, #{identity})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    void insert(UserDO userDO);

    @Select("select count(*) from user where email=#{email}")
    Integer countByEmail(@Param("email") String email);

    @Select("select count(*) from user where phone_number=#{phoneNumber}")
    Integer countByPhoneNumber(@Param("phoneNumber") Encrypt phoneNumber);

    @Select("select * from user where email=#{email}")
    UserDO selectByEmail(@Param("email") String email);

    @Select("select * from user where phone_number=#{phoneNumber}")
    UserDO selectByPhoneNumber(@Param("phoneNumber") Encrypt phoneNumber);
}
